package com.ledim.widget.recyclerview.loadmore;

import android.support.annotation.LayoutRes;
import com.ledim.widget.recyclerview.BaseViewHolder;

/**
 * Created by ccx on 2016/12/05.
 * Rv 上拉加载view基类
 */

public abstract class LoadMoreView {

    public static final int STATUS_DEFAULT = 1;
    public static final int STATUS_LOADING = 2;
    public static final int STATUS_FAIL = 3;
    public static final int STATUS_END = 4;

    protected int mLoadMoreStatus = STATUS_DEFAULT;
    private boolean mLoadMoreEndGone = false;

    public void setLoadMoreStatus(int loadMoreStatus) {
        this.mLoadMoreStatus = loadMoreStatus;
    }

    public int getLoadMoreStatus() {
        return mLoadMoreStatus;
    }

    public void convert(BaseViewHolder holder) {
        switch (mLoadMoreStatus) {
            case STATUS_LOADING:
                onLoading(holder);
                break;
            case STATUS_END:
                onEnd(holder);
                break;
            case STATUS_FAIL:
                onFailed(holder);
                break;
            case STATUS_DEFAULT:
                onNormal(holder);
                break;
        }
    }

    public final void setLoadMoreEndGone(boolean loadMoreEndGone) {
        this.mLoadMoreEndGone = loadMoreEndGone;
    }

    public final boolean isLoadEndMoreGone() {
        return mLoadMoreEndGone;
    }

    /**
     * load more layout
     *
     * @return
     */
    public abstract
    @LayoutRes
    int getLayoutId();

    public abstract void onLoading(BaseViewHolder holder);

    public abstract void onEnd(BaseViewHolder holder);

    public abstract void onFailed(BaseViewHolder holder);

    public abstract void onNormal(BaseViewHolder holder);

}
